package com.miao.controller;

import com.miao.dto.BindMediaAndTeachPlanDto;
import com.miao.dto.TeachPlanDto;
import com.miao.service.ITeachplanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//课程计划管理相关接口
@RestController
@RequestMapping("/content/teachplan")
public class TeachPlanController {
    @Autowired
    private ITeachplanService iTeachplanService;

    //查看课程计划，返回的是树形结构
    @GetMapping("/{courseId}/tree-nodes")
    public List<TeachPlanDto> getTreeNodes(@PathVariable Long courseId){
        return iTeachplanService.selectTeachById(courseId);
    }

    //新增修改大小课程计划
    @PostMapping
    public void saveTeachPlan(@RequestBody TeachPlanDto teachPlanDto){
        iTeachplanService.savePlan(teachPlanDto);
    }

    //删除课程计划
    @DeleteMapping("/{id}")
    public void deleteTeachPlan(@PathVariable Long id){
        iTeachplanService.deletePlan(id);
    }
    //计划上移
    @PostMapping("/moveup/{id}")
    public void moveUp(@PathVariable Long id){
        iTeachplanService.moveUp(id);
    }
    //计划下移
    @PostMapping("/movedown/{id}")
    public void moveDown(@PathVariable Long id){
        iTeachplanService.moveDown(id);
    }
    //课程信息和媒资信息绑定
    @PostMapping("/association/media")
    public void associationMedia(@RequestBody BindMediaAndTeachPlanDto bindMediaAndTeachPlanDto){
        iTeachplanService.associateWithMedia(bindMediaAndTeachPlanDto);
    }

}
